package com.cn.integration.common;

import com.cn.common.enums.UserTypeEnum;
import com.cn.common.model.AuthUser;
import com.cn.common.utils.http.ServletUtil;
import com.cn.common.utils.jwt.JwtUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class BaseController {

    private static final Logger log = LoggerFactory.getLogger(BaseController.class);


    public BaseController() {
    }

    public AuthUser getAuthUser() {
        return JwtUtil.getUser(ServletUtil.getRequest());
    }

    public boolean isPersonalUser() {
        AuthUser user = this.getAuthUser();
        return user.getUserType() == UserTypeEnum.DRIVER.getCode() || user.getUserType() == UserTypeEnum.PAYEE.getCode();
    }

}